<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>爬虫首页</title>
    <script src="www/js/jquery-1.9.0.min.js"></script>
</head>
<body>
<script>
    location.href="www/main";
</script>
<%--<button id="zc">注册</button>
<button id="dl">登录</button>
<button id="xg">修改个人信息</button>
<button id="xgpwd">修改密码</button>
<button id="reg">注册管理员</button>
<button id="log">登录管理员</button>
<button id="uppwd">管理员改密码</button>
<button id="add">添加评价</button>
<form action="" method="post" enctype="multipart/form-data" id="f">
    <input type="file" name="icon">
    <input type="text" name="nickname">
    <input type="RADIO" value="0" name="sex">男
    <input type="RADIO" value="1" name="sex">女
    <input type="text" name="age">
    <input type="text" name="phone">
    <button type="submit" id="sub">提交</button>
</form>

<img id="icon" src="" alt="">
<a href="/download?book_id=2">a标签下载</a>
<div id="ret">
<c:forEach items="${requestScope.search_book}" var="item">
    ${item}
</c:forEach>
    <c:forEach items="${requestScope.history_book}" var="item">
        ${item}
    </c:forEach>
    <script src="/get_look?chapter_id=33" charset="gb2312"></script>
</div>--%>

<script>

    $('#zc').click(function(){
        $.ajax({
            url:"/register_user",
            data:{name:"admin",pwd:"admin"},
            success:function(o){
                alert(o);
            }
        })

    });
    $('#dl').click(function(){
        $.ajax({
            url:"/login_user",
            data:{name:"admin",pwd:"admin"},
            success:function(o){
                console.log(o);
                if(o.substring(0,1)=="{"){
                    var user=JSON.parse(o);
                    console.log(user);
                    $("#ret").html(user["name"]);
                    document.getElementById("icon").src=user["icon"];
                }else{
                    $("#ret").html(o);
                }

            }
        })

    });
    $('#sub').click(function(){
        var f=new FormData($('#f')[0]);
        f.append("id",1);
        $.ajax({
            url:"/update_userinfo",
            type:"post",
            data:f,
            contentType:false,
            processData:false,
            success:function(o){
                $("#ret").html(o);
            }
        })
        return false;
    });
    $('#xgpwd').click(function(){
        $.ajax({
            url:"/update_userpwd",
            data:{name:"admin",pwd:"admin"},
            success:function(o){
                $("#ret").html(o);
            }
        })
    });
    $('#reg').click(function(){
        $.ajax({
            url:"/register_manage",
            data:{name:"admin",pwd:"admin"},
            success:function(o){
                $("#ret").html(o);
            }
        })
    });
    $('#log').click(function(){
        $.ajax({
            url:"/login_manage",
            data:{name:"admin",pwd:"root"},
            success:function(o){
                console.log(o);
                if(o.substring(0,1)=="{"){
                    var user=JSON.parse(o);
                    console.log(user);
                    $("#ret").html(user["name"]);
                }else{
                    $("#ret").html(o);
                }

            }
        })
    });
    $('#uppwd').click(function(){
        $.ajax({
            url:"/update_manage",
            data:{name:"admin",pwd:"root"},
            success:function(o){
                $("#ret").html(o);
            }
        })
    });
    $('#add').click(function(){
        $.ajax({
            url:"/option",
            data:{book_id:1,user_id:1,option:"写得不错！",score:10},
            success:function(o){
                $("#ret").html(o);
            }
        })
    });
</script>
</body>
</html>
